package com.ict.ais.common;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * Created by chenlong on 2017/3/10.
 */
public class ProperGet {
    private String hive_ip;
    private String hive_port;
    private String hive_user;
    private String hive_psword;

    @Override
    public String toString() {
        return "ProperGet{" +
                "hive_ip='" + hive_ip + '\'' +
                ", hive_port='" + hive_port + '\'' +
                ", hive_user='" + hive_user + '\'' +
                ", hive_psword='" + hive_psword + '\'' +
                '}';
    }

    public ProperGet(String road){
        Properties prop =  new  Properties();
        InputStream ins = this.getClass().getResourceAsStream(road);
        try  {
            //BufferedReader 防中文乱码
            BufferedReader bf = new BufferedReader(new InputStreamReader(ins));
            prop.load(bf);

            hive_ip =prop.getProperty("hive_ip");
            hive_port = prop.getProperty("hive_port");
            hive_user =prop.getProperty("hive_user");
            hive_psword =prop.getProperty("hive_psword");

            close(ins);
        }  catch  (IOException e) {
            close(ins);
            e.printStackTrace();
        }
    }

    private void close(InputStream ins){
        try{
            ins.close();
        }catch (Exception e){
            System.out.println("输入流关闭异常："+e);
        }
    }

    public String getHive_ip() {
        return hive_ip;
    }

    public String getHive_port() {
        return hive_port;
    }

    public String getHive_user() {
        return hive_user;
    }

    public String getHive_psword() {
        return hive_psword;
    }
}
